OB.Emes_ActionButton = OB.Emes_ActionButton || {};

var QualityPutdata = {};
var QualityResultId = "";
var QualityView = null;
// 员工基础信息文件查看
OB.Emes_ActionButton.ExhibitionPicture = function(d, b) {
	var e = b.activeView.viewGrid;
	var a = e.getSelectedRecord();
	OB.Emes_ActionButton.MyRefresh=function(){
		b.refresh();
	}
	if (a != null) {
			// 选择纪录行
			var selectRecords = {
				"USER_NAME" : a.user$_identifier,   				//员工姓名
				"SEX" : a.sex,		//性别
				"AGE" : a.age,			//年龄
				"TELEPHONE" : a.telephone,					//联系电话
				"HIREDATE" : a.hiredate,					//入职日期
			};
			QualityResultId = a.id;
			QualityPutdata = selectRecords;
			QualityView = b;
			
			certification = a.certification; //资格证
			copies = a.copies;               //身份证
			healthcard = a.healthcard;       //体检报告
			paysecrecy = a.paysecrecy;       //工资保密协议
			photo = a.photo;     			 //寸照
			resign = a.resign;  			 //离职证明
			saqa = a.saqa;					 //学历证明
			signboard = a.signboard;		 //新员工标识牌
			undertaking = a.undertaking;     //安全承诺书
			
			isc.External_xhibitionPicture.create().show();
		
	}else{
		isc.showMessage("请选择记录！");
	}
	
};

// checkbox
isc.defineClass("UsingCheckboxItem", "CheckboxItem");

isc.defineClass('External_xhibitionPicture', isc.OBPopup);

isc.External_xhibitionPicture.addProperties({
	width: 400,
	height: 200,
	align: "center",
	showMinimizeButton : false,
	showMaximizeButton : false,
	

	qualityResultForm : null,

	initWidget : function() {
		this.qualityResultForm = isc.DynamicForm.create({
			ID : "qualityResult",
			canEdit : true,
			width : "100%",
			height : 200,
			fields : [{
				width : "15%",
				type : 'text',
				readOnlyDisplay : "static",
				canEdit : false,
				startRow : true,
				value : QualityPutdata.USER_NAME,
				title : '员工姓名',
				name : 'USER_NAME'
			}, {
				width : "25%",
				type : 'text',
				readOnlyDisplay : "static",
				canEdit : false,
				startRow : false,
				value : QualityPutdata.SEX,
				title : '性别',
				name : 'SEX'
			}, {
				width : "25%",
				type : 'text',
				readOnlyDisplay : "static",
				canEdit : false,
				startRow : false,
				value : QualityPutdata.AGE,
				title : '年龄',
				name : 'AGE'
			},{
				width : "25%",
				type : 'text',
				readOnlyDisplay : "static",
				canEdit : false,
				startRow : false,
				value : QualityPutdata.TELEPHONE,
				title : '联系电话',
				name : 'TELEPHONE'
			},{
				width : "25%",
				type : 'text',
				readOnlyDisplay : "static",
				canEdit : false,
				startRow : false,
				value : QualityPutdata.HIREDATE,
				title : '入职日期',
				name : 'HIREDATE'
			}]
		
		});
		
		
		
        this.createFileButton();
		
        
      //Add the elements into a layout   
		this.items = [ isc.VLayout.create({
			defaultLayoutAlign : "center",
			align : "center",
			width : "100%",
			layoutMargin : 15,
			membersMargin : 20,
			members : [
					isc.HLayout
							.create({
								defaultLayoutAlign : "center",
								align : "right",
								width : "100%",
								height : "80%",
								members : [ this.qualityResultForm ]
							}),
					isc.HLayout
							.create({
								defaultLayoutAlign : "center",
								align : "right",
								membersMargin : 10,
								marginBottom : 10,
								members : [
										this.idCardPicture,
										this.EmployeelogoPicture,
										this.InchPicture,
										this.HealthPicture,
										this.Educationicture,
										this.certificatePicture,
										this.LeavingPicture,
										this.PromisePicture,
										this.WagePicture ]
							}) ]
		}) ];

		this.Super('initWidget', arguments);
	},
	createFileButton: function() {
		var _self = this;
		this.idCardPicture = isc.OBFormButton.create({
			ID:'idCardPicture',
			title : '身份证复印件',
			action : function() {
				
			    var  IDcopies = copies;               //身份证
				
				if(IDcopies){
					
//				    var pdfname =  IDcopies.substring(IDcopies.lastIndexOf("\\") + 1);
//				    
//					isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(IDcopies) + "&online=true&fileName=" + encodeURIComponent(pdfname)}).show();
					_self.showFileWin(IDcopies);
				}else{
					top.isc.showMessage("该员工未上传身份证复印件。",top.isc.OBMessageBar.TYPE_SUCCESS);
				}
			}
		});
		OB.Emes_ActionButton.MyRefresh=function(){
			b.refresh();
		}
		this.EmployeelogoPicture = isc.OBFormButton.create({
			ID:'EmployeelogoPicture',
			title : '新员工标识牌',
			action : function() {
				
				var  newsignboard = signboard;		 //新员工标识牌
				
				if(newsignboard){

//				    var pdfname =  newsignboard.substring(newsignboard.lastIndexOf("\\") + 1);
//					isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(newsignboard) + "&online=true&fileName=" + encodeURIComponent(pdfname)}).show();
					_self.showFileWin(newsignboard);
				}else{
					top.isc.showMessage("该员工未上传员工标识牌",top.isc.OBMessageBar.TYPE_SUCCESS);
				}
			}
		});
		this.InchPicture = isc.OBFormButton.create({
			ID:'InchPicture',
			title : '寸照',
			action : function() {
				
				var newphoto = photo;     			 //寸照
				
				if(newphoto){

//				    var pdfname =  newphoto.substring(newphoto.lastIndexOf("\\") + 1);
//					isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(newphoto) + "&online=true&fileName=" + encodeURIComponent(pdfname)}).show();
					_self.showFileWin(newphoto);
				}else{
					top.isc.showMessage("该员工未上传寸照",top.isc.OBMessageBar.TYPE_SUCCESS);
				}
			}
		});
		
		this.HealthPicture = isc.OBFormButton.create({
			ID:'HealthPicture',
			title : '健康证/体检证明',
			action : function() {

			 var newhealthcard = healthcard;       //体检报告
				
				if(newhealthcard){

//				    var pdfname =  newhealthcard.substring(newhealthcard.lastIndexOf("\\") + 1);
//					isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(newhealthcard) + "&online=true&fileName=" + encodeURIComponent(pdfname)}).show();
					_self.showFileWin(newhealthcard);
				}else{
					top.isc.showMessage("该员工未上传体检证明",top.isc.OBMessageBar.TYPE_SUCCESS);
				}
				
			}
		});
		
		this.Educationicture = isc.OBFormButton.create({
			ID:'Educationicture',
			title : '学历证明复印件',
			action : function() {

				var newsaqa = saqa;					 //学历证明
				
				if(newsaqa){

//				    var pdfname =  newsignboard.substring(43);
//					isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(newsaqa) + "&online=true&fileName=" + pdfname}).show();
					_self.showFileWin(newsaqa);
				}else{
					top.isc.showMessage("该员工未上传体学历证明复印件",top.isc.OBMessageBar.TYPE_SUCCESS);
				}
			}
		});
		
		this.certificatePicture = isc.OBFormButton.create({
			ID:'certificatePicture',
			title : '资格证',
			action : function() {
				

				var newcertification = certification; //资格证
				if(newcertification){

//				    var pdfname =  newsignboard.substring(43);
//					isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(newcertification) + "&online=true&fileName=" + pdfname}).show();
					_self.showFileWin(newcertification);
				}else{
					top.isc.showMessage("该员工未上传体资格证",top.isc.OBMessageBar.TYPE_SUCCESS);
				}
			}
		});
		
		this.LeavingPicture = isc.OBFormButton.create({
			ID:'LeavingPicture',
			title : '离职证明',
			action : function() {

			var	newresign = resign;  			 //离职证明
				
				if(newresign){

//				    var pdfname =  newsignboard.substring(43);
//					isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(newresign) + "&online=true&fileName=" + pdfname}).show();
					_self.showFileWin(newresign);
				}else{
					top.isc.showMessage("该员工未上上传离职证明",top.isc.OBMessageBar.TYPE_SUCCESS);
				}
			}
		});
		
		this.PromisePicture = isc.OBFormButton.create({
			ID:'PromisePicture',
			title : '安全生产承诺书',
			action : function() {
			
				var	newundertaking = undertaking;     //安全承诺书
			
			if(newundertaking){

//			    var pdfname =  newsignboard.substring(43);
//				isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(newundertaking) + "&online=true&fileName=" + pdfname}).show();
				_self.showFileWin(newundertaking);
			}else{
				top.isc.showMessage("该员工未上上传安全承诺书",top.isc.OBMessageBar.TYPE_SUCCESS);
			
			}
			
			}
		});
		
		this.WagePicture = isc.OBFormButton.create({
			ID:'WagePicture',
			title : '工资保密协议',
			action : function() {
				

		 var newpaysecrecy = paysecrecy;       //工资保密协议
			
			if(newpaysecrecy){
				
//				var pdfname =  newsignboard.substring(43);
//				isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(newpaysecrecy) + "&online=true&fileName=" + pdfname}).show();
				_self.showFileWin(newpaysecrecy);
			}else{
				top.isc.showMessage("该员工未上上传工资保密协议",top.isc.OBMessageBar.TYPE_SUCCESS);				
			}
			
			}
		});
		
		//查看文件窗口
		this.showFileWin = function(filePath) {
			var fileName =  filePath.substring(filePath.lastIndexOf("\\") + 1);
			isc.EMES_Window_View.create({
				url: "DownFileServlet.html?path=" + encodeURIComponent(filePath) 
					+ "&online=true&fileName=" + encodeURIComponent(fileName)
			}).show();
		};
		
		this.Super('initWidget', arguments);
	},

}); 